<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="css/font-awesome.min.css"/>
    <link rel="stylesheet" href="css/font-awesome-ie7.min.css"/>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/paging.css">
    <link rel="stylesheet" href="css/admin.css"/>
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <![endif]-->
    <!--[if lt IE 10]>
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/jquery-placeholder/2.0.8/jquery.placeholder.min.js"></script>
    <![endif]-->
</head>
<body style="background: #d2d6de;">
<div class="login-box">
    <!-- /.login-logo -->
    <div class="login-box-body">
        <!--<div class="logo"><img src="images/logo.png"></div>-->
        <h3>微信小程序管理平台</h3>

        <div>
            <div class="form-group has-feedback">
                <input id="userName" type="text" class="form-control" name="account" placeholder="用户名">
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input id="password" type="password" class="form-control" name="pwd" placeholder="密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>

            <div style="margin-left: -18px;text-align: center">
                <button id="loginBtn" type="submit" class="btn btn-primary" style="width: 310px;">登录</button>
            </div>
        </div>
        <!-- /.login-box-body -->
    </div>
</div>

<script src="js/jquery.min-1-11-3.js"></script>
<script type="text/javascript">
        $(function () {
            $("#loginBtn").click(function () {
                login();
            });

            $(document).keydown(function (event) {
                if (event.keyCode == 13) {
                    $("#loginBtn").click();
                }
            });

        });
        //登录方法
        function login() {
            $("#loginBtn").html("登陆中...");
            var url="apis/user/login";
            var account=$("#userName").val();
            var password=$("#password").val();
            if(account ==""){
                alert("用户名不能为空");
                return;
            }
            if(password==""){
                alert("请输入密码");
                return;
            }
            var data={
                "account":account,
                "password":password
            };
//            console.log(data);
            $.ajax({
                url:url,
                type:'post',
                data: {
                    "user": JSON.stringify(data)
                },
                dataType:'json',
                contentType : 'application/json',
                success:function (res) {
//                    console.log(res);
                    if(res.httpCode == 200){
                        $("#loginBtn").html("登陆成功");

//                        if(res.data.usertype !=0){
                            window.location.href="user-order.html";
//                        }else {
//                            alert("抱歉，您没有登陆权限");
//                        }

                    }
                    else{
                        $("#loginBtn").html("登陆");
                        alert(res.msg);
                    }
                },
                error:function (res) {
                    alert(res.msg);
                }
            })

        }
</script>
</body>
</html>